<?php
session_start();
isLogin();

if(isset($_POST["Submits"])){
	if($_REQUEST['act']=='modify'){
		$sql="update ".$prefix."searchkey set s_name='".$_POST['s_name']."' where s_id=".$_REQUEST['s_id'];
		if(mysql_query($sql)){
			reload_js("修改成功","index.php?cmd=setkey");
		}else{
			reload_js("修改失败，原因：程序错误，请联系技术人员进行修改","index.php");
		}
	}else{
		$sql="insert into ".$prefix."searchkey (s_name) values('".$_POST['s_name']."')";
		if(mysql_query($sql)){
			reload_js("添加成功","index.php?cmd=setkey");
		}else{
			reload_js("添加失败，原因：程序错误，请联系技术人员进行修改","index.php");
		}
	}
}

if($_REQUEST['act']=='del'){
	$sql="delete from ".$prefix."searchkey where s_id=".$_REQUEST['s_id'];
	if(mysql_query($sql)){
		reload_js("","index.php?cmd=setkey");
	}else{
		reload_js("删除失败，原因：程序错误，请联系技术人员进行修改","index.php");
	}
}
?>
<script language="javascript" src="../templates/<?php echo $moban;?>/js/common.js"></script>
<script language="javascript">
changeWebTitle('热门搜索关键字设置');
</script>

<div class="ContentRight">
    <div class="ContentRightTop">
      <div class="BarLeft"></div>
      <div class="ContentRightTopText">热门搜索关键字设置</div>
      <div class="BarRight"></div>
      <div class="Cal"></div>
    </div>
    <div class="ContentRightBox">
	<form action="" name="linkform" method="post">
      <table width="100%" cellpadding="0" class="Table1" bordercolor="#4ab902" border="1" cellspacing="0">
        <tr>
          <td align="center">ID</td>
          <td height="25" align="center">名称</td>
          <td align="center">操作</td>
        </tr>
		<?php 
		$result=mysql_query("select * from ".$prefix."searchkey order by s_id desc");
		while($arr=mysql_fetch_array($result)){
		?>
        <tr>
          <td width="22%" align="center"><?php echo $arr['s_id']?></td>
          <td width="58%" height="25" align="center"><?php echo $arr['s_name']?></td>
          <td width="20%" align="center"><a href="<?php echo "?cmd=".$_REQUEST['cmd']."&s_id=".$arr['s_id']."&act=modify"?>">修改</a>&nbsp;<a href="<?php echo "?cmd=".$_REQUEST['cmd']."&s_id=".$arr['s_id']."&act=del"?>" onclick="return confirm('您确认删除该条记录？删除后将不可恢复！');">删除</a></td>
        </tr>
		<?php }
		
		$s_name="";
		if($_REQUEST['act']=='modify'){
			$result=mysql_query("select * from ".$prefix."searchkey where s_id=".$_REQUEST['s_id']);
			if($arr=mysql_fetch_array($result)){
				$s_name=$arr['s_name'];
			}
		}
		?>
        <tr>
          <td height="25" colspan="3" align="left">&nbsp;</td>
        </tr>
        <tr>
          <td align="right">关键字：</td>
          <td height="25" colspan="2" align="left"><input name="s_name" type="text" id="s_name" size="40"  value="<?php echo $s_name?>"/></td>
        </tr>
        <tr>
          <td align="right">显示关键字个数：</td>
          <td height="25" colspan="2" align="left">请到&nbsp;&nbsp;系统配置&nbsp;&nbsp;修改</td>
        </tr>
        <tr>
          <td align="right">版权所有：</td>
          <td height="25" colspan="2" align="left"><a href="http://www.fengsh8.com" target="_blank">风尚淘客程序</a></td>
        </tr>
        <tr>
          <td align="right">&nbsp;</td>
          <td height="25" colspan="2" align="left">
            <input name="Submits" type="submit" id="Submits" value=" 提  交" />            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="Reset" type="reset" id="Reset" value=" 重 置 " />          </td>
        </tr>
      </table>
	  </form>
    </div>
    <div class="Cal"></div>
  </div>